extends CharacterBody2D
 

var move_speed : int = 50
var input_vector: Vector2
var face : Vector2
@export var is_game_start : bool = false

@onready var animation_tree: AnimationTree = $AnimationTree

func _physics_process(delta: float) -> void:
	
	if is_game_start:
		#玩家输入方向向量
		input_vector = Input.get_vector("left","right","up","down")
		
		#记录玩家当前朝向
		if not input_vector == Vector2.ZERO:
			update_blend_position(input_vector)
		
		velocity = input_vector * move_speed 
		move_and_slide()


#在混合动画树中调整玩家朝向
func update_blend_position(dirction : Vector2):
	animation_tree.set("parameters/StateMachine/MoveState/MoveState/blend_position",dirction)
